import constants as con
import pygame

import xzlabel

class Bubble(pygame.sprite.Sprite):
    image = None

    def __init__(self,parent):
        pygame.sprite.Sprite.__init__(self)

        self.parent = parent
        self.sprites = parent.sprites

        self.width = int(con.window_size[0] * 0.04)
        self.height = int(con.window_size[1] * 0.07)

        if Bubble.image is None:
            Bubble.image = con.load_image('dat_speech.png')

        self.image = pygame.transform.scale(Bubble.image, (self.width, self.height))
        self.need = parent.need
        self.body = None

        self.rect = pygame.Rect(0,0,self.width,self.height)
        self.rect.bottomleft = self.parent.rect.topleft

        self.sprites.add(self)
        self.label = xzlabel.Label(self)

    def purge(self):
        self.sprites.remove(self)
        self.label.purge()
